package com.ruoyi.camp.api;


import com.ruoyi.camp.domain.Appointment;
import com.ruoyi.camp.service.IAppointmentService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;


import java.util.List;

import static com.ruoyi.common.core.domain.AjaxResult.success;
import static com.ruoyi.common.utils.PageUtils.startPage;

@Api(value = "营地预约", tags = {"营地预约"})
@RestController
@RequestMapping("/wechat/appointment")
public class WxAppointmentController extends BaseController {

    @Autowired
    private IAppointmentService appointmentService;
    /**
     * 查询营地预约列表
     */
    @ApiOperation("查询营地预约列表")
    @GetMapping("/list")
    public TableDataInfo list(Appointment appointment)
    {
        List<Appointment> list = appointmentService.selectAppointmentList(appointment);
        return getDataTable(list);
    }
    /**
     * 获取营地预约详细信息
     */
    @ApiOperation("获取营地预约详细信息")
    @GetMapping(value = "/{appointId}")
    public AjaxResult getInfo(@PathVariable("appointId") String appointId)
    {
        return success(appointmentService.selectAppointmentByAtId(appointId));
    }
    /**
     * 新增营地预约
     */
    @ApiOperation("新增营地预约")
    @PostMapping
    public AjaxResult add(@RequestBody Appointment appointment)
    {
        return toAjax(appointmentService.insertAppointment(appointment));
    }
    /**
     * 修改营地预约
     */
    @ApiOperation("修改营地预约")
    @PutMapping
    public AjaxResult edit(@RequestBody Appointment appointment)
    {
        return toAjax(appointmentService.updateAppointment(appointment));
    }


}
